home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: HELP IN WRITING MY FIRST PROGRAM ASSINGMENT
- Date: 22 Feb 1996 12:44:54 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gikk6INNjiv@keats.ugrad.cs.ubc.ca>
- References: <3127dd4f.19010083@news.planet.net>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <3127dd4f.19010083@news.planet.net>,
- David <cygnusx@planet.net> wrote:
- >I have to write a program that uses a array, reads a value and puts
- >all the values in ascending order and then print it out. array size
- >100 values . any ideas ?? will be grateful.
-
- This reads string values, until you hit Ctrl-D (or whatever your terminal
- system uses to mean "EOF") and sorts them lexicographically.
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(){int i,j;char x[256],*y[100];for(i=0;i<100&&fgets(x,256,stdin);i++)
- i[y]=strdup(x);qsort(y,i,sizeof(char*),(int(*)(const void*,const void*))strcmp);
- for(j=0;j<i;j++)fputs(j[y],stdout);return 0;}
-
- --
-
-